import Vue from "vue";
import Router from "vue-router";
// import HelloWorld from '@/components/HelloWorld'

Vue.use(Router);

// 引入路由组件
import Home from "../pages/Home/index.vue";
// import Login from "../pages/Login/index.vue";
// import Register from "../pages/Register/index.vue";
import Search from "../pages/Search/index.vue";

// 登录注册组件-静态组件引入
import Login from "../views/Login/index";
import Register from "../views/Register/index";

export default new Router({
  routes: [
    {
      path: "/home",
      component: Home,
      meta: { show: true }
    },
    {
      path: "/login",
      component: Login,
      meta: { show: false }
    },
    {
      // path: "/search:keyword", 传参的时候参考
      path: "/search",
      component: Search,
      meta: { show: true },
      name: "search"
      // 对象的写法--就是额外的给对象穿的props参数
      // props: { a: 1, b: 2, c: 3 },
      // 函数的写法
      // props: $route => ({ keyword: $route.params.keyword, k: $route.query.k })
    },
    {
      path: "/register",
      component: Register,
      meta: { show: false } //通过meta占位符来标识组件
    },

    // 重定向
    {
      path: "/",
      redirect: "/home" //默认打开首页
    }
  ]
});
